<?php
namespace App\Http\Forms;

use App\Library\OSS;
use App\Modules\Coupon\Models\Coupon;
use Kris\LaravelFormBuilder\Form;

class PageConfigForm extends Form
{
    public function buildForm()
    {
        $key = "video"."/".uniqid().random_int(10, 99);
        $this
            ->add('can_apply_partner', 'checkbox', [
                'label' => "开放合伙人申请入口",
                'rules' => 'nullable|integer',
            ])
            ->add('customer_service_mobile', 'text', [
                'label' => "客服电话",
                'rules' => 'required|string',
            ])
            ->add('customer_service_qr_code', 'image', [
                'label' => "客服二维码",
                'rules' => 'required|string',
                'type' => 'customer_service',
            ])
            ->add('share_image', 'image', [
                'label' => "分享图片",
                'rules' => 'required|string',
                'type' => 'customer_service',
            ])
            ->add('partner_bg', 'image', [
                'label' => "申请合伙人背景",
                'rules' => 'required|string',
                'type' => 'bg',
            ])
            ->add('rule_video', 'video', [
                'label' => "返利规则视频",
                'rules' => 'nullable|string',
                'type' => 'rule_video',
                'async' => true,
                'config' => OSS::instance('video')->getSign($key),
            ])
//            ->add('rebate_rule_text', 'textarea', [
//                'label' => "返利规则介绍 *",
//                'attr' => ['id' => 'editor'],
//                'rules' => 'required|string',
//            ])
//            ->add('rule_image', 'image_list', [
//                'label' => "返利规则介绍 *",
//                'rules' => 'required|array',
//                'type' => 'rule_image',
//            ])
            ->add('submit', 'submit', [
                'attr' => ['class' => "form-control btn btn-success"],
                'label' => '保存',
            ]);
    }
}
